﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>退回</title>
    <!--
    1, 退回界面。
    2，需要 FK_Flow, FK_Node,WorkID, FID.
    3, 调用方法 ReturnWork.htm?FK_Flow=001&FK_Node=103&WorkID=232&FID=23
    -->
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <script type="text/javascript" src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-1.7.2.min.js"></script>
    <!-- 导入配置文件. -->
    <!-- 该文件可以被集成厂商自己定义风格,可以自己修改,以达到流程设计器与自己的系统风格统一. -->
    <link href="../../DataUser/Style/ccbpm.css" rel="Stylesheet" />

    <script type="text/javascript" src="../Scripts/config.js"></script>
    <style type="text/css">
        body {
            background: transparent;
        }

            body div {
                text-align: left;
                margin: 20px auto;
            }

        #Message {
            width: 100%;
        }
    </style>
    <script type="text/javascript">
        var pageData = {};
        $(function () {

            //初始化页面退回信息
            
            pageData = {
                FK_Node: GetQueryString('FK_Node'),
                WorkID: GetQueryString('WorkID'),
                FID: GetQueryString('FID'),
                Message: GetQueryString('Info'),
                FK_Flow: GetQueryString("FK_Flow")
            };

            $.ajax({
                type: 'post',
                async: true,
                data: null,
                url: Handler + "?DoType=ReturnToNodes&FK_Node=" + pageData.FK_Node + "&WorkID=" + pageData.WorkID + "&FID=" + pageData.FID + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') == 0) {
                        console.error("退回窗口错误信息" + data);
                        return;
                    }
                    var returnNodeArr = JSON.parse(data);
                    var DDL_NodesHtml = '';

                    $.each(returnNodeArr, function (i, returnNode) {
                        DDL_NodesHtml += '<option selected="selected" value="' + returnNode.No + '">' + returnNode.Name + '=&gt;' + returnNode.RecName + '</option>';
                    });

                    $('#DDL_Nodes').html(DDL_NodesHtml);
                    $(".wait").hide();
                }
            });

        });

        //确定 退回 执行退回操作
        function ReturnWork(isBack) {
            //WorkID, this.FID, this.FK_Node
            $.ajax({
                type: 'post',
                async: true,
                data: {},
                url: Handler + "?DoType=DoReturnWork&FK_Flow=" + pageData.FK_Flow + "&WorkID=" + pageData.WorkID + "&FID=" + pageData.FID + "&FK_Node=" + pageData.FK_Node + "&ReturnToNode=" + $('#DDL_Nodes option:checked').val() + '&ReturnMsg=' + $('#TB_Doc').val() + "&IsBack=" + isBack + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                        window.parent.returnWorkWindowClose(data);
                    } else {
                        $('body').append($('<div>'+data+'</div>'));
                    }
                }
            });
            $(".foot").hide();
        }

        //取消退回
        function Close() {
            if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                window.parent.returnWorkWindowClose("取消");
            }
            else {
                $('body').append($('<div>' + "已取消操作" + '</div>'));
            }
        }
      
    </script>
</head>
<body>
    <div class="wait" style="text-align: center;">页面数据正在加载中，请稍候......</div>
<div>
    请选择要退回到的节点:
    <select id="DDL_Nodes" name="DDL_Nodes" style="width: 77%;"></select>
</div>
<div>
    退回原因：
    <textarea id="TB_Doc" name="TB_Doc" style="vertical-align: top; width: 98%;"></textarea>
</div>
<div> 上传附件：</div>
<div style="position: fixed; bottom: 0px; right: 0px;" class="foot">
    <input type="button" value="确定退回" onclick="ReturnWork(0);"/>
    <input type="button" value="退回后并发送给我" onclick="ReturnWork(1);"/>
    <input type="button" value="关闭" onclick="Close();"/>
</div>
</body>
</html>
